$(document).ajaxSend(function(event,xhr,options){
    xhr.setRequestHeader("user_token", localStorage.getItem("userToken"));
});

$(document).ajaxError(function (event,xhr,options,exc) {
   if (xhr.status == 401) {
       location.href = "blog_login.html";
   }
})

function getInfo(url) {

    $.ajax({
        type: "get",
        url: url,
        success: function (result) {
            if (result != null && result.code == "SUCCESS" && result.data != null) {
                $(".card h3").text(result.data.userName);
                $(".card a").attr("href", result.data.githubUrl);
            }


        }
    });
}

function logout() {
    localStorage.removeItem("userToken");
    localStorage.removeItem("userId");

    location.href = "blog_login.html";
}